package com.study.hadoop.mapreduce.partition;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

/**
 * @Author huang
 * @Date 2022/1/3 17:04
 * @Version 1.0
 */
public class ProvincePartioner extends Partitioner<Text,FlowBean> {

    @Override
    public int getPartition(Text text, FlowBean flowBean, int numPartitions) {
        String phone = text.toString();
        String prePhone = phone.substring(0, 2);
        int part = 4;
        if (prePhone.equals("135"))
            part = 0;
        else if (prePhone.equals("136"))
            part = 1;
        else if (prePhone.equals("137"))
            part = 2;
        else if (prePhone.equals("138"))
            part = 3;
        return part;
    }
}
